<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //   es6中允许函数中 形参赋初始值
        // 默认值参数位置一般靠后
        function add(a = 1, b = 1, c = 1) {
            return a + b + c;
        }
        let result = add();
        console.log(result);

        //-------------------
        //和解构赋值结合使用
        obj1 = {
            host: '3000',
            username: 'root',
            password: 'root',
            port: 3306
        }
        function obj({ host = 6222, username, password, port }) {
            console.log(host);
            console.log(username);
            console.log(password);
            console.log(port);
        }
        obj(obj1);
    </script>
</body>

</html>